#include "CBase.h"
#include "SGD Wrappers/CSGD_Direct3D.h"
#include "SGD Wrappers/CSGD_TextureManager.h"
#include "CEvent.h"
#include "SGD Wrappers/SGD_Math.h"
#include "CGame.h"

CBase::CBase()
{
	m_uiRefCount = 1;
	SetPosX(0);
	SetPosY(0);
	SetType(TYPE);
	SetVelX(0);
	SetVelY(0);
}
CBase::~CBase()
{

}
void CBase::Init()
{

}
void CBase::Update(float fDelta)
{
	SetPosX( GetPosX() + (GetVelX() * fDelta) );
	SetPosY( GetPosY() + (GetVelY() * fDelta) );
}
void CBase::Render()
{
}
RECT CBase::GetCollisionRect()
{
	RECT temp;
	temp.top = (LONG)(GetPosY() - GetHalfHeight());
	temp.bottom = (LONG)(GetPosY() + GetHalfHeight());
	temp.left = (LONG)(GetPosX() - GetHalfWidth());
	temp.right = (LONG)(GetPosX() + GetHalfWidth());
	return temp;
}
RECT CBase::GetDrawRect()
{
	RECT temp;
	temp.top = (LONG)(GetPosY() - GetHalfHeight() - CGame::GetInstance()->RectCamera().top);
	temp.bottom = (LONG)(GetPosY() + GetHalfHeight() - CGame::GetInstance()->RectCamera().top);
	temp.left = (LONG)(GetPosX() - GetHalfWidth() - CGame::GetInstance()->RectCamera().left);
	temp.right = (LONG)(GetPosX() + GetHalfWidth() - CGame::GetInstance()->RectCamera().left);
	return temp;
}
bool CBase::Collision(CBase* pBase)
{
	RECT temp;
	RECT t1 = pBase->GetCollisionRect();
	RECT t2 = GetCollisionRect();

	if(IntersectRect(&temp, &t1, &t2))
		return true;
	else
		return false;
}

void CBase::HandleEvent(CEvent *pEvent)
{

}
